<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        canvas {
            border: 1px solid red;
        }
    </style>
</head>

<body>
    <canvas width="800" height="600"></canvas>
    <script>
        window.onload = function () {
            //1:获取canvas对象
            let c = document.querySelector('canvas');
            //2：创建实例
            let ctx = c.getContext('2d');
            ctx.moveTo(100, 100);
            ctx.lineTo(100, 300);
            ctx.lineTo(300, 300);
            ctx.lineWidth = '30'
            //    ctx.lineJoin = 'round'
            ctx.lineJoin = 'bevel'
            // ctx.lineJoin = 'miter' //默认
            ctx.closePath()
            ctx.strokeStyle = 'red';
            ctx.stroke()
            ctx.beginPath()

            ctx.moveTo(400, 100);
            ctx.lineTo(400, 300);
            ctx.lineTo(500, 300);
            ctx.lineWidth = '30'
            ctx.lineCap = 'round'
            // ctx.lineCap = 'square'
            ctx.lineJoin = 'miter' //默认

            ctx.strokeStyle = 'green';
            ctx.stroke()
            ctx.beginPath()

        }
    </script>
</body>

</html>